#include "Comm.hpp"
int main()
{
    Fifo fifo(Path); 
    //打开文件
    int rfd = open(Path, O_RDONLY);
    if(rfd < 0)
    {
        cerr<<"open fail, errno: "<<errno<<"stringerrno: "<<strerror(errno)<<endl;
        return 1;
    }
    //读文件
    char buffer[1024];
    while (true)
    {
        ssize_t n = read(rfd, buffer, sizeof(buffer)-1);
        if(n > 0)//读取成功
        {
            buffer[n] = 0;
            cout<<"client say: "<<buffer<<endl;
        }
        else if(n == 0) //读停止
        {
            cout<<"read quit!"<<endl;
            break;
        }
        else 
        {
            cerr<<"read fail, errno: "<<errno<<"stringerrno: "<<strerror(errno)<<endl;
            break;
        }
    }
    //关闭文件
    close(rfd);
    return 0;
}
